<?php

namespace utility\zego_live;


use ZEGO\ZegoServerAssistant;
use ZEGO\ZegoErrorCodes;
require_once dirname(__FILE__).'/token04/auto_loader.php';
// require_once dirname(__FILE__).'/token40/src/ZEGO/ZegoServerAssistant.php';
// require_once dirname(__FILE__).'/token40/src/ZEGO/ZegoErrorCodes.php';
class Zego
{
    // 请将 appID 修改为你的 appId，appid 为 数字
    // 举例：1234567890
    private $app_id = "";
    // 请将 serverSecret 修改为你的 serverSecret，serverSecret 为 string
    // 举例：'fa94dd0f974cf2e293728a526b028271'
    private $server_secret = "";
    // 请将 userId 修改为用户的 userId，userId为string
    private $userId = "";
    private $payload = "";


    public function __construct($app_id,string $server_secret) {
        $this->app_id = $app_id;//
        $this->server_secret = $server_secret;//
    }

    public function getToken($user_id,string $payload = '',int $ex_time = 3600) { 
        $token = ZegoServerAssistant::generateToken04($this->app_id, $user_id, $this->server_secret, $ex_time, $payload);
        if( $token->code !== ZegoErrorCodes::success ){
        return [$token->message,''];
        }
        return ['',$token->token];
    }



}